<template>
    <div class="header">
        <div class="breadcrumb">
            <el-icon class="breadcrumb-icon"><Location /></el-icon>
            <span class="breadcrumb-text">当前位置：</span>
            <span class="breadcrumb-current">系统数据</span>
        </div>
        <div class="user-info">
            <el-avatar size="small" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
            <el-dropdown trigger="click" @command="handleCommand">
                <span class="el-dropdown-link">
                    管理员 <el-icon class="el-icon--right"><ArrowDown /></el-icon>
                </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item command="logout">
                            <el-icon><SwitchButton /></el-icon>
                            <span>退出登录</span>
                        </el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
    </div>
</template>

<script setup>
import { Location, ArrowDown, SwitchButton } from '@element-plus/icons-vue'

const emit = defineEmits(['logout'])

const handleCommand = (command) => {
    if (command === 'logout') {
        emit('logout')
    }
}
</script>

<style scoped>
.header {
    background: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
}

.breadcrumb {
    display: flex;
    align-items: center;
}

.breadcrumb-icon {
    margin-right: 8px;
    color: #409EFF;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.el-dropdown-link {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}
</style>